<div class="cont">
    <div class="position " id="page_title">
        <img alt="位置图标" src="dist/images/position.png"/>人事管理&gt;奖惩管理
        <a ng-click="openDetail()" ng-hide="$needClientCache" title="打开新窗口查看">
        	<i class="large External icon"></i>
        </a>
    </div>
    <div class="mybackground">
	    <div class="ui top attached tabular menu">
		    <a class="item" ng-click="go('/jiangcheng')">处罚</a>
		    <a class="item active">嘉奖</a>
		    <a class="item" ng-click="go('/offer')">特殊贡献</a>
	    </div>
        <div class="cont_fr_top">
			<div class="cont_fr_btn">
				<div style="height: 20px;">
					<div class="fr">
						<button class="cont_f_btn3"  ng-click="addShow()"><i class="ui add icon"></i>添加</button>
					</div>
				</div>
			</div>
            <div class="menus">
                <div class="menus_con">
                    <div class="ui form">
                        <div class="four fields">
                            <div class="inline field">
                                <label style="margin-right: 2.8em;">工号</label>
                                <input type="text" ng-model="psearch.yggh" ng-keyup="$event.keyCode == 13 && search()" placeholder="工号" style="width:160px" />
                            </div>
                            <div class="inline field">
                                <label style="margin-right: 2.8em;">姓名</label>
                                <input type="text" ng-model="psearch.name" ng-keyup="$event.keyCode == 13 && search()" placeholder="姓名" style="width:160px" />
                            </div>
		                    <div class="inline field">
		                        <label style="margin-right: 2.8em;">部门</label>
		                        <select ng-model="psearch.sector" class="ui dropdown">
                                    <option value="">选择部门</option>
		                        	<option value="{{vitem.sector_id}}" ng-repeat="vitem in sectors|tree2Arr:'_child'">{{vitem.rep}}{{vitem.sector_name}}</option>
		                        </select>
		                    </div>
                        </div>
						<div class="four fields">
                            <div class="inline field">
                                <label>开始日期</label>
                                <div class="ui left icon input">
                                    <input type="text" ng-model="psearch.commdateA" datetimepicker id="commdateA" format='YYYY-MM-DD' class="input_text" placeholder="惩罚时间" ng-keyup="$event.keyCode == 13 && search()">
                                    <i class="calendar icon"></i>
                                </div>
                            </div>
                            <div class="inline field">
                                <label>结束日期</label>
                                <div class="ui left icon input">
                                    <input type="text" ng-model="psearch.commdateB" datetimepicker id="commdateB" format='YYYY-MM-DD' class="input_text" placeholder="惩罚时间" ng-keyup="$event.keyCode == 13 && search()">
                                    <i class="calendar icon"></i>
                                </div>
                            </div>
		                    <div class="inline field">
		                        <label>嘉奖缘由</label>
		                        <select ng-model="psearch.type" class="ui dropdown" ng-options="yp.k as yp.v for yp in cfcause">
		                        	<option value="" selected disabled hidden>全部</option>
		                        </select>
		                    </div>
		                    <div class="inline field">
		                        <label>嘉奖标准</label>
		                        <select ng-model="psearch.class" class="ui dropdown" ng-options="cp.k as cp.v for cp in cfways">
		                        	<option value="" selected disabled hidden>全部</option>
		                        </select>
		                    </div>
						</div>
                        <div class="fields">
                            <div class="inline field">
                                <button class="clear_btn" style="margin-left: 4.8em;" ng-click="search()">查询</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="menus">
        <div class="menus_table">
            <table class="ui celled yellow striped table">
                <thead>
                    <tr>
                        <th>姓名</th>
                        <th>工号</th>
                        <th>部门</th>
                        <th>岗位</th>
                        <th>在职状态</th>
                        <th>嘉奖时间</th>
                        <th>嘉奖缘由</th>
                        <th>嘉奖方式</th>
                        <th class="center aligned">操作</th>
                    </tr>
                </thead>
                <tbody ng-hide="exist">
                    <tr ng-repeat="vlist in sdata_list">
                        <td>{{::vlist.ext_name}}</td>
                        <td>{{::vlist.ext_yggh}}</td>
                        <td>{{::vlist.sector_name}}</td>
                        <td>{{::vlist.role_name}}</td>
                        <td>{{::vlist.ext_user_status}}</td>
                        <td>{{::vlist.comm_date}}</td>
                        <td>{{::vlist.comm_reason}}</td>
                        <td>{{::vlist.comm_clsay}}</td>
                        <td class="center aligned">
                            <a class="ui link" ng-click="editDetail(vlist.comm_id)">编辑</a>    
                            <a class="ui link" ng-click="pdelete(vlist.comm_id)">删除</a>    
                        </td>
                    </tr>
                </tbody>
                <tbody ng-show="!sdata_list || sdata_list.length == 0">
                    <tr>
                        <td colspan=10 style="text-align:center;margin-top:10px" class="null_data">没有找到数据~~~</td>
                    </tr>
                </tbody>
            </table>
            <div class="ui pagination menu" jspagination page-object="vPage" page-func="getDataList" ng-show="vPage.pageAll>1"></div>
        </div>
    </div>
</div>
<div class="ui small addfrm modal">
    <i class="close icon"></i>
    <div class="header_h4"> 添加嘉奖 </div>
    <div class="content">
        <from class="ui form add" id="addfrm" name="addfrm">
            <div class="fields">
                <div class="field inline required" >
                    <label>嘉奖时间</label>
                    <div class="ui left icon input">
                        <input type="text" ng-model="addinfo.comm_date" datetimepicker name="addinfo_comm_date" format='YYYY-MM-DD' class="input_text" placeholder="嘉奖时间" />
                        <i class="calendar icon"></i>
                    </div>
                </div>
            </div>
            <div class="fields">
                <div class="inline field required">
                    <label>嘉奖缘由</label>
                    <select ng-model="addinfo.comm_type" name="addinfo_comm_type" class="ui dropdown">
                        <option value="{{yp.k}}"   ng-repeat = "yp in cfcause">{{yp.v}}</option>
                    </select>
                </div>
            </div>
            <div class="fields" >
                <div class="inline field required">
                    <label>缘由说明</label>
                    <input type="text" ng-model="addinfo.comm_reason" name="addinfo_comm_reason" placeholder="缘由说明" style="width:600px;" maxlength="50" />
                </div>
            </div>
            <div class="fields">
                <div class="inline field required">
                    <label>嘉奖方式</label>
                    <select ng-model="addinfo.comm_class" name="addinfo_comm_class" class="ui dropdown">
                        <option value="{{cp.k}}" ng-repeat = "cp in cfways">{{cp.v}}</option>
                    </select>
                </div>
            </div>
            <div class="fields" >
                <div class="inline field required">
                    <label>方式说明</label>
                    <input type="text" ng-model="addinfo.comm_clsay" name="addinfo_comm_clsay" placeholder="方式说明" style="width:600px;" maxlength="50" />
                </div>
            </div>
            <div class="fields">
                <div class="field inline required">
                    <label>添加人员</label>
                    <div class="ui input">
                        <select class="ui fluid search dropdown" ng-model="addinfo.user_id" name='addinfo_user_id' id='addinfo_user_id' multiple="">
                          <option value="{{opu.stridlist}}" ng-repeat="opu in uslist">{{opu.strvaluelist}}</option>
                        </select>
                    </div>
                   
                </div>
            </div>
            <div class="fields">
                <div class="inline field">
                    <label style="margin-right: 2.8em;">备注</label>
                    <textarea ng-model="addinfo.comm_beizhu"  placeholder="备注" style="width:600px;height:70px;" maxlength="200"></textarea>
                </div>
            </div>
            <div class="ui basic red pointing prompt label transition " ng-show="add_hite_msg" >{{addhiteMsg}}</div>
        </from>
    </div> 
    <div class="actions" style="text-align: center;">
        <button class="ui positive button "> 确 认 </button> 
        <button class="ui grey button negative">取消</button>
    </div>
</div>

<div class="ui small editfrm modal">
    <i class="close icon"></i>
    <div class="header_h4"> 编辑嘉奖 </div>
    <div class="content">
        <from class="ui form edit" id="editfrm" name="editfrm">
            <div class="fields">
                <input type="hidden" ng-model="editinfo.comm_id" />
                <div class="field inline required" >
                    <label>嘉奖时间</label>
                    <div class="ui left icon input">
                        <input type="text" ng-model="editinfo.comm_date" datetimepicker name="editinfo_comm_date" format='YYYY-MM-DD' class="input_text" placeholder="嘉奖时间" />
                        <i class="calendar icon"></i>
                    </div>
                </div>
            </div>
            <div class="fields">
                <div class="inline field required">
                    <label>嘉奖缘由</label>
                    <select ng-model="editinfo.comm_type" name="editinfo_comm_type" id="editinfo_comm_type" class="ui dropdown" id="editinfo_type">
                        <option value="{{yp.k}}"   ng-repeat = "yp in cfcause">{{yp.v}}</option>
                    </select>
                </div>
            </div>
            <div class="fields" >
                <div class="inline field required">
                    <label>缘由说明</label>
                    <input type="text" ng-model="editinfo.comm_reason" name="editinfo_comm_reason" placeholder="缘由说明" style="width:600px;" maxlength="50" />
                </div>
            </div>
            <div class="fields">
                <div class="inline field required">
                    <label>嘉奖方式</label>
                    <select ng-model="editinfo.comm_class" name="editinfo_comm_class" id="editinfo_comm_class" class="ui dropdown">
                        <option value="{{cp.k}}" ng-repeat = "cp in cfways">{{cp.v}}</option>
                    </select>
                </div>
            </div>
            <div class="fields" >
                <div class="inline field required">
                    <label>方式说明</label>
                    <input type="text" ng-model="editinfo.comm_clsay" name="editinfo_comm_clsay" placeholder="方式说明" style="width:600px;" maxlength="50" />
                </div>
            </div>
            <div class="fields">
                <div class="inline field">
                    <label style="margin-right: 2.8em;">备注</label>
                    <textarea ng-model="editinfo.comm_beizhu"  placeholder="备注" style="width:600px;height:70px;" maxlength="200"></textarea>
                </div>
            </div>
            <div class="ui basic red pointing prompt label transition " ng-show="edit_hite_msg" >{{edithiteMsg}}</div>
        </from>
    </div> 
    <div class="actions" style="text-align: center;">
        <button class="ui positive button "> 确 认 </button> 
        <button class="ui grey button negative">取消</button>
    </div>
</div>

<div class="ui modal modalSuccess" style="text-align: center;">
    <div class="header center aligned">提示</div>
    <div class="content center aligned">
        <i class="huge green check circle outline icon"></i>
        <p style="padding-top: 15px;" id="successMsg"></p>
    </div>
</div>

<div class="ui modal modalFail" style="text-align: center;">
    <div class="header center aligned">提示</div>
    <div class="content center aligned">
        <i class="huge red remove circle outline icon"></i>
        <p style="padding-top: 15px;" id="failMsg"></p>
    </div>
</div>

<div class="ui modal modalComfirm" style="text-align: center;">
    <div class="header center aligned">确认操作</div>
    <div class="content center aligned">
        <i class="huge red remove circle outline icon"></i>
        <p style="padding-top: 15px;" id="comfirmMsg"></p>
    </div>
    <div class="actions" style="text-align: center;">
        <button class="ui positive button "> 确 认 </button> 
        <button class="ui grey button negative">取消</button>
    </div>
</div>

<script>
    $.fn.form.settings.rules.checkUser = function() {
        var isValid = false;
        var cbody = angular.element(document.body);
        var rootScope = cbody.scope().$root;
        var nseluser = $('#addinfo_user_id').val();

        if (rootScope.strhrtemp) {
            isValid = true;
        }
        if (nseluser != null) {
            isValid = true;
        }
        return isValid;
    };
    $(function() {
        $('.ui.dropdown').dropdown();
        $('#addfrm').form({
            on: 'blur',
            inline: true,
            fields: {
                addinfo_user_id: {
                    identifier: 'addinfo_user_id',
                    rules: [{
                        type: 'checkUser',
                        prompt: '没有选择员工'
                    }]
                },
                addinfo_comm_date: {
                    identifier: 'addinfo_comm_date',
                    rules: [{
                        type: 'empty',
                        prompt: '日期不能为空'
                    }]
                },
                addinfo_comm_type: {
                    identifier: 'addinfo_comm_type',
                    rules: [{
                        type: 'empty',
                        prompt: '缘由类别没有选择'
                    }]
                },
                addinfo_comm_reason: {
                    identifier: 'addinfo_comm_reason',
                    rules: [{
                        type: 'empty',
                        prompt: '缘由说明不能为空'
                    }]
                },
                addinfo_comm_class: {
                    identifier: 'addinfo_comm_class',
                    rules: [{
                        type: 'empty',
                        prompt: '嘉奖方式没有选择'
                    }]
                },
                addinfo_comm_clsay: {
                    identifier: 'addinfo_comm_clsay',
                    rules: [{
                        type: 'empty',
                        prompt: '嘉奖方式说明不能为空'
                    }]
                },
            }
        });

        $('#editfrm').form({
            on: 'blur',
            inline: true,
            fields: {
                editinfo_comm_date: {
                    identifier: 'editinfo_comm_date',
                    rules: [{
                        type: 'empty',
                        prompt: '日期不能为空'
                    }]
                },
                editinfo_comm_type: {
                    identifier: 'editinfo_comm_type',
                    rules: [{
                        type: 'empty',
                        prompt: '缘由类别没有选择'
                    }]
                },
                editinfo_comm_reason: {
                    identifier: 'editinfo_comm_reason',
                    rules: [{
                        type: 'empty',
                        prompt: '缘由说明不能为空'
                    }]
                },
                editinfo_comm_class: {
                    identifier: 'editinfo_comm_class',
                    rules: [{
                        type: 'empty',
                        prompt: '嘉奖方式没有选择'
                    }]
                },
                editinfo_comm_clsay: {
                    identifier: 'editinfo_comm_clsay',
                    rules: [{
                        type: 'empty',
                        prompt: '嘉奖方式说明不能为空'
                    }]
                },
            }
        });

    });


</script>